Skip to content

Replace Cache API with KV cache layer#7

Merged
gavyncaldwell merged 6 commits intomainfrom
fix/buffer-cached-responses
Mar 13, 2026
Merged

Replace Cache API with KV cache layer#7
gavyncaldwell merged 6 commits intomainfrom
fix/buffer-cached-responses

Conversation

@gavyncaldwell
Copy link
Collaborator

Summary

  • Add Cloudflare KV namespace binding for query caching
  • Create db/kv-cache.ts with kvCached() helper that reads from KV first, falls back to Turso
  • Wrap all 18 read server functions and 6 sitemap queries with KV cache
  • Remove Cache API edge cache buffering (KV replaces it)
  • Update cache purge script to bulk-delete KV keys alongside edge cache purge

Why

Bot/crawler traffic was burning through Turso row reads. KV reads are free on the Workers paid plan, so this eliminates DB cost from repeat visits while keeping data fresh via cache purge after seed runs.

Test plan

  • Deployed to production, verified second requests are ~50% faster (KV hit)
  • Pages render correctly with cached data
  • Search still hits Turso live (not cached)
  • TypeScript and lint pass

@cloudflare-workers-and-pages
Copy link

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
unclouded ea56bc2 Commit Preview URL

Branch Preview URL
Mar 13 2026, 05:23 PM

@gavyncaldwell gavyncaldwell merged commit 234d24f into main Mar 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant